package org.example.k8s_cloudplatform.entity.res;

import lombok.Data;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor;

@SuppressWarnings("unused")
@Data
@AllArgsConstructor
public class Result {
    @JSONField(ordinal = 1)
    private Integer code;

    @JSONField(ordinal = 2)
    private String message;

    @JSONField(ordinal = 3)
    private Object data;

    public static Result success() {
        return success(null);
    }

    public static Result success(Object data) {
        return success("success", data);
    }

    public static Result success(String message, Object data) {
        return new Result(0, message, data);
    }

    public static Result fail() {
        return fail(null);
    }

    public static Result fail(Object data) {
        return fail("fail", data);
    }

    public static Result fail(String message, Object data) {
        return new Result(-1, message, data);
    }

    public static Result exception() {
        return new Result(500, "server error", null);
    }
    public static Result exception(String message) {
        return new Result(500, message, null);
    }

    public static Result tokenTimeOut() {
        return new Result(601, "token out of time", null);
    }

    public static Result tokenError() {
        return new Result(602, "Token permission error!", null);
    }
}